<?php
use \PsiFramework\Classes\Util\UI\Printer;
use \PsiFramework\Classes\Util\UI\HTML;

$application = $response->getAttribute("object");
$parameters = null ;
if (!is_null($application)) {
    $parameters = $application->getParameters();
}
$objectType = $response->getAttribute("objectType");
?>
<form
    class="editForm"
    method="POST"
    action="<?php Printer::display(HTML::linkHref('action=CMS.Save&type='.$objectType));?>">
    <?php
    if ($application != null) {
    ?>
    <input
        type="hidden"
        name="id"
        value="<?php Printer::display($application->getId()); ?>" />
    <?php
    }
    ?>
    <div class="label">
        <span class="titre">Nom :</span>
        <input
            class="firstInput"
            type="text"
            name="name"
            value="<?php if ($application != null) Printer::display($application->getName()); ?>" />
    </div>
    <div class="label">
        <span class="titre">Adresse e-mail :</span>
        <input
            class="firstInput"
            type="email"
            name="email"
            value="<?php if (!is_null($parameters)) Printer::display($parameters->get('email')); ?>" />
    </div>
    <div class="label" id="inscription">
        <?php
        $inscription = null ;
        if (!is_null($parameters) && !is_null($parameters->get('inscription_message'))) {
            $inscription = $parameters->get('inscription_message')->getObject();
        }
        ?>
        <span class="titre">e-mail de confirmation d'inscription :</span>
        <input
            class="firstInput pageSelecterInscription"
            type="text"
            name="inscription_name"
            value="<?php if (!is_null($inscription)) Printer::display($inscription->getTitle()); ?>" />
        <input
            class="firstInput inputIdInscription"
            type="hidden"
            name="inscription_id"
            value="<?php if (!is_null($inscription)) Printer::display($inscription->getId()); ?>" />
    </div>
    <div class="label" id="new_pasword">
        <?php
        $newPassword = null ;
        if (!is_null($parameters) && !is_null($parameters->get('new_password_message'))) {
            $newPassword = $parameters->get('new_password_message')->getObject();
        }
        ?>
        <span class="titre">e-mail d'envoi d'un nouveau mot de passe :</span>
        <input
            class="firstInput pageSelecterNewPassword"
            type="text"
            name="new_password_name"
            value="<?php if (!is_null($newPassword)) Printer::display($newPassword->getTitle()); ?>" />
        <input
            class="firstInput inputIdNewPassword"
            type="hidden"
            name="new_password_id"
            value="<?php if (!is_null($newPassword)) Printer::display($newPassword->getId()); ?>" />
    </div>
    <div class="label" id="top_menu">
        <?php
        $topMenu = null ;
        if (!is_null($parameters) && !is_null($parameters->get('top_menu'))) {
            $topMenu = $parameters->get('top_menu')->getObject();
        }
        ?>
        <span class="titre">Menu haut :</span>
        <div></div>
    </div>
    <input type="submit" value="OK" />
</form>
<script type="text/javascript">
    $(document).ready(function() {
        $(".pageSelecterInscription").autocomplete({
            source: "?service=ListPages&format=json",
            select: function(event, ui) {
                $(".pageSelecterInscription").val(ui.item.label);
                $(".inputIdInscription").val(ui.item.id);
            }
        });
    });
    $(document).ready(function() {
        $(".pageSelecterNewPassword").autocomplete({
            source: "?service=ListPages&format=json",
            select: function(event, ui) {
                $(".pageSelecterNewPassword").val(ui.item.label);
                $(".inputIdNewPassword").val(ui.item.id);
            }
        });
    });
</script>
